﻿using Candy.Web;
using Candy.Web.Data;
using System;
using System.Collections.Generic;
using System.ServiceModel.DomainServices.Client;

namespace Candy.Model
{
    public interface IDataService
    {
        EntitySet<ProjectDto> Projects { get; }
        EntitySet<FamilyDto> Families { get; }
        EntitySet<GeneDto> Genes { get; }
        EntitySet<GenotypeDto> Genotypes { get; }
        EntitySet<DatabaseDto> Databases { get; }
        EntitySet<GeneAnnotationDto> GeneAnnotations { get; }
        EntitySet<PhylogenyDto> Phylogenies { get; }
        

        CandyDataContext DataContext { get; }

        void SubmitAsync(Action<CandySubmitOperation> callback);

        ProjectDto LoadedProject { get; }

        void ProjectExistsAsync(string projectName, Action<CandyInvokeOperation<bool>> callback);

        void LoadProjectListAsync(Action<CandyLoadOperation<ProjectDto>> callback);

        void RefreshFamiliesAsync(Action<CandyLoadOperation<FamilyDto>> callback);

        void FamilyExistsAsync(int projectId, int selfFamilyId, string familyName, Action<CandyInvokeOperation<bool>> callback);

        void GeneIdentifierExistsAsync(int projectId, int selfGeneId, string geneIdentifier, Action<CandyInvokeOperation<bool>> callback);

        void GeneNameExistsAsync(int projectId, int selfGeneId, string geneName, Action<CandyInvokeOperation<bool>> callback);



        void LoadGenesAsync(Action<CandyLoadOperation<GeneDto>> callback);

        void CreateJobAsync(Action<CandyInvokeOperation<List<BlastJobDto>>> callback, BlastJobDefinitionDto val);

        void CreateJobsAsync(Action<CandyInvokeOperation<List<BlastJobDto>>> callback, List<BlastJobDefinitionDto> val);


        void LoadJobsAsync(Action<CandyLoadOperation<BlastJobDto>> callback);


        void RefreshJobsAsync(Action<CandyLoadOperation<BlastJobDto>> callback, IEnumerable<BlastJobDto> jobs);

        void LoadBlastHitsAsync(int jobId, Action<CandyLoadOperation<HitResultDto>> callback);

        void RefreshGenotypes(Action<CandyInvokeOperation> callback);

        void LoadGeneAnnotaionAsync(int geneId, Action<CandyLoadOperation<GeneAnnotationDto>> callback);

        void LoadPhylogeniesAsync(int familyId, Action<CandyLoadOperation<PhylogenyDto>> callback);

        void Initialize(ProjectDto project, Action<CandyInvokeOperation<bool>> callback = null);
        void DeInitialize();

        event EventHandler ProjectInitialized;
        event EventHandler ProjectDeInitialized;
    }
}
